{% extends "base_BAM.html" %}
{% load staticfiles %}

{% block title %}
    图灵系统 - 提问
{% endblock %}

{% block style %}
    <link rel="stylesheet" type="text/css" href="{% static 'css/tagify.css' %}">
{% endblock %}

{% block content %}
    <div id="showRankList">
          <form method="post" action="/Admin/ShowRankList/">
            <select name="activityID">
                {% for i in Activities %}
                <option value='{{i.DateID}}'>{{i.activityAbstract}}</option>
                {% endfor %}
            </select>
            <input type="submit" value="提交">
        </form>
    </div>
<br>
    <div id="mainbar" class="container question_box" >
    <form id="post-form" class="post-form" action="{% url 'app_TuringClass:NotificationSubmit' %}" method="post" onsubmit="return myonsubmit(event)">
        <input type="hidden" name="qualityBanWarningShown" value="False"/>
        <input type="hidden" name="priorAttemptCount" value="0"/>
        <input type="hidden" name="warntags" />

        <div style="position: relative;">
            <table>
                <tr>
                    <h4 style="font-weight: bold;">标题</h4>
                    <input id="title" name="title" type="text" maxlength="300" tabindex="100" placeholder="不超过30字" class="ask-title-field" >
                </tr>
            </table>
        </div>
    <br>
    <div id="post-editor" >
       <div style="position: relative;">
			        <!--tool bar可以先不加？
			            <div id="wmd-button-bar" class="wmd-button-bar"></div>
                   -->
                   <table>
                    <tr>
                     <h4 style="font-weight: bold;">
                      编写内容详情
                      <a href="#" title="上传图片说明：在【上传】处点击【选择文件】-->选择图片-->选完后点击【上传到服务器】-->在【图像信息】处点击【确定】">
                       <span class="glyphicon glyphicon-info-sign pull-right" style="font-size: 15px; color: #000;"></span>
                   </a>
               </h4>
           </tr>
           <tr>
              <script type="text/javascript" src="{%static 'ckeditor/ckeditor.js' %}"></script>
              <textarea cols="80" id="content" name="post-text" class="ckeditor" rows="10"></textarea>
              <script type="text/javascript">
                 function getContent(){
                    return CKEDITOR.instances.content.getBody().getText();
						          		//return CKEDITOR.instances.content.getData();    //获取textarea的值
                                  }
                              </script>
                          </tr>
                      </table>

                  </div>


              </div>

              <br>
              <div id="type">
                  <label><input name="type" type="radio" value="News" checked="True">新闻</label>
                  <label><input name="type" type="radio" value="Announcement">公告</label>
              </div>
              <div id="question-only-section" class="pull-right" >
                <div class="form-item">
                  <button id="submit-button" class="form-sumbit" >发布</button>
              </div>

          </div>


      </form>
    </div>
{% endblock %}

{% block other_script %}
    <script type="text/javascript">
        function myonsubmit(event) {
            // body...
            var regx=new RegExp('[a-zA-z]|[\u4e00-\u9fa5]|[0-9]');
            var reg=/^((<p>(\&nbsp;( )?)*<\/p>)*\n?)*$/;
            if(!regx.test(document.getElementById('title').value)){
            	window.alert("标题不能为空！");
            	return false;
            }
            if (reg.test(CKEDITOR.instances.content.getData())) {
            	window.alert("详情不能为空！");
            	return false;
            }
            $('#post-form').find('button[id="submit-button"]').attr('disabled','disabled');
            return true;
            	//document.getElementById('post-form').submit();
        }
    </script>
{% endblock %}
</html>
